document.getElementById("listbox").style.height="630px";	 //初始化新用户列表--列表盒子高度
document.getElementById("indexSort").style.display = "none"; //排名列表隐藏
//投票成功提示文字
function success(){
	document.getElementById("success").style.display = "block";
	document.getElementById("success").style.opacity = 0;
	var hitimer,hitimer1;
	hitimer = setTimeout(function(){
		document.getElementById("success").style.opacity = 1;
	},10)
	hitimer = setTimeout(function(){
		document.getElementById("success").style.opacity = "0";
		nexhide();
		clearInterval(hitimer);
	},900)
}
function nexhide(){
	document.getElementById("success").style.display = "none";
}
//点击投票按钮
function vote1(e){
	var parent = e.parentNode.parentNode;
	var pNum = parent.getElementsByTagName("p")[3];
	var num = parseInt(pNum.innerHTML.slice(3));
	num+=1;
	pNum.innerHTML =  "票数:"+ num;
	e.onclick = function(){}//不能第二次点击
	//初始化love
	e.innerHTML = '<span></span>';
	e.firstChild.style.opacity= 1;
	e.firstChild.style.width= "0px";
	e.firstChild.style.height= "0px";
	e.firstChild.style.top= "-10px";
	e.firstChild.style.right= "10px";
	var timer5,timer6,timer9;
	timer5 = setTimeout(function(){ //显示love
		showlove();
	},10)
	timer6 = setTimeout(function(){ //隐藏love
		hidelove();
	},1000)
	function showlove(){
		clearInterval(timer5);
		e.firstChild.style.right= "0px";
		e.firstChild.style.top= "-20px";
		e.firstChild.style.width= "20px";
		e.firstChild.style.height= "20px";
		success();
	}
	function hidelove(){
		clearInterval(timer6);
		e.firstChild.style.opacity= 0;
		//按钮背景
		e.style.background = "#969696";
		e.innerHTML = '已投票';
		e.style.height = "24px";
	}
}
function vote2(e){
	var parent = e.parentNode.parentNode;
	var pNum = parent.getElementsByTagName("span")[2];
	var num = parseInt(pNum.innerHTML);
	num+=1;
	pNum.innerHTML = num;
	e.onclick = function(){}//不能第二次点击
	//初始化love
	e.innerHTML = '<span></span>';
	e.firstChild.style.opacity= 1;
	e.firstChild.style.width= "0px";
	e.firstChild.style.height= "0px";
	e.firstChild.style.top= "-8px";
	e.firstChild.style.right= "8px";
	var timer7,timer8;
	timer7 = setTimeout(function(){ //显示love
		showlove();
	},10)
	timer8 = setTimeout(function(){ //隐藏love
		hidelove();
	},1000)
	function showlove(){
		clearInterval(timer7);
		e.firstChild.style.right= "0px";
		e.firstChild.style.top= "-16px";
		e.firstChild.style.width= "16px";
		e.firstChild.style.height= "16px";
		success();
	}
	function hidelove(){
		clearInterval(timer8);
		e.firstChild.style.opacity= 0;
		//按钮变化
		e.className = "sortVote";
		e.innerHTML = '已投票';
		
	}
}
//标题背景移动
~(function(){
	var timer,len,len1,len2 = null;
	len = 100;
	timer = setInterval(function(){
		len -=1;
		len1 = (len)+"%";
		len2 = (100-len)*-1+"%";
		if(len<=0){
			len = 100;
		}else{
			document.getElementById("titlebg").style.left = len1;
			document.getElementById("titlebg2").style.left = len2;
		}
		
	},100)
	
})()

//切换列表
var isrun = true;
var sortbox = document.getElementById("indexSort");
function judge(){
	//给排名列表已投票的人加样式(已投票的sortVote)
	var hadvote = sortbox.getElementsByClassName("sortVote");
	for(var i=0,len=hadvote.length;i<len;i++){
		hadvote[i].innerHTML = "已投票";
	}
	//判断切换的列表
	if(isrun == true){
		changebox();
	}else if(isrun ==false){
		showbtn();
	}else{
		console.log("太快了")
	}
}
//切换至排名列表
function changebox(){
	listbox.style.height="560px";//列表盒子高度-用户列表
	indexSort.style.display = "block";//显示-排名列表
	document.getElementById("applylist").style.display = "none";//隐藏-新人列表
	document.getElementById("btnbox").style.height = "0px";//按钮盒子隐藏
	isrun = false;
	console.log("切换到排名");
}
//切换至用户展示列表
function showbtn(){
	listbox.style.height="630px";	//列表盒子高度-排名
	indexSort.style.display = "none";//隐藏-排名列表
	document.getElementById("applylist").style.display = "block";//显示-新人列表
	document.getElementById("btnbox").style.height = "34px";//显示-按钮盒子
	isrun = true;
	console.log("切换到排名");
}
